/*
 *  Copyright (C) 2009  Peter Kist & Jan Ripke
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "Producer.h"

#include <Core/Interface/Logic.h>
#include <Modules/Logic/Manager.h>
#include <Core/Mediator/Request.h>

namespace galaxy {

    namespace logic {

        namespace gamestate {

            Producer::Producer(Manager& manager)
            {
                m_Manager = &manager;
            }

            Producer::~Producer()
            {
            }

            bool Producer::handleRequest(mediator::Request const &request,
                mediator::RequestResultPtr& result)
            {
                if (request.type() == MODULE_TYPE_LOGIC_SET_STATE) {
                    logic::StateRequest const & stateRequest = 
                        dynamic_cast<logic::StateRequest const&>(request);
                    m_Manager->changeState(stateRequest.m_StateName);

                    return true;
                }
                return false;
            }

        } // namespace gamestate
    } // namespace logic
} // namespace galaxy
